From: Florian Müllner Date: Mon, 17 Oct 2011 14:00:13 +0000 (+0200) Subject: Revert "dash: Ignore hiding items in _adjustIconSize()" X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~7441 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=adef2009a524b164fa4dd00f7af1b4da1df0c818;p=gnome-shell.git Revert "dash: Ignore hiding items in _adjustIconSize()" Ooops, a patch got lost in rebase. This reverts commit b07f9932db71dc0b62f041280685f742b7dee312. --- diff --git a/js/ui/dash.js b/js/ui/dash.js index aa5f97270..91c63e913 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -37,7 +37,6 @@ DashItemContainer.prototype = { this.child = null; this._childScale = 1; this._childOpacity = 255; - this.animatingOut = false; }, _allocate: function(actor, box, flags) { @@ -116,7 +115,6 @@ DashItemContainer.prototype = { return; } - this.animatingOut = true; this.childScale = 1.0; Tweener.addTween(this, { childScale: 0.0, @@ -179,6 +177,12 @@ RemoveFavoriteIcon.prototype = { this._iconBin._delegate = this; this.setChild(this._iconBin); + this.hiding = false; + }, + + animateOutAndDestroy: function() { + DashItemContainer.prototype.animateOutAndDestroy.call(this); + this.hiding = true; }, _createIcon: function(size) { @@ -310,12 +314,15 @@ Dash.prototype = { _endDrag: function() { this._clearDragPlaceholder(); if (this._favRemoveTarget) { + this._favRemoveTarget.actor.hide(); + this._adjustIconSize(); + this._favRemoveTarget.actor.show(); + this._favRemoveTarget.animateOutAndDestroy(); this._favRemoveTarget.actor.connect('destroy', Lang.bind(this, function() { this._favRemoveTarget = null; })); - this._adjustIconSize(); } DND.removeDragMonitor(this._dragMonitor); }, @@ -394,18 +401,8 @@ Dash.prototype = { }, _adjustIconSize: function() { - // For the icon size, we only consider children which are "proper" - // icons (i.e. ignoring drag placeholders) and which are not - // animating out (which means they will be destroyed at the end of - // the animation) - let iconChildren = this._box.get_children().filter(function(actor) { - return actor._delegate.child && - actor._delegate.child._delegate && - actor._delegate.child._delegate.icon && - !actor._delegate.animatingOut; - }); - - if (iconChildren.length == 0) { + let children = this._box.get_children(); + if (children.length == 0) { this._box.add_style_pseudo_class('empty'); return; } @@ -415,39 +412,23 @@ Dash.prototype = { if (this._maxHeight == -1) return; + let iconChildren = children.filter(function(actor) { + return actor.visible && + actor._delegate.child && + actor._delegate.child._delegate && + actor._delegate.child._delegate.icon; + }); - let themeNode = this.actor.get_theme_node(); - let maxAllocation = new Clutter.ActorBox({ x1: 0, y1: 0, - x2: 42 /* whatever */, - y2: this._maxHeight }); - let maxContent = themeNode.get_content_box(maxAllocation); - let availHeight = maxContent.y2 - maxContent.y1; - let spacing = themeNode.get_length('spacing'); - - - let firstIcon = iconChildren[0]._delegate.child._delegate.icon; - - // Icons may be animating, so enforce the current icon size - // during the size request - let [currentWidth, currentHeight] = firstIcon.icon.get_size(); - - firstIcon.icon.set_size(this.iconSize, this.iconSize); - let [minHeight, natHeight] = iconChildren[0].get_preferred_height(-1); - - firstIcon.icon.set_size(currentWidth, currentHeight); - - - // Subtract icon padding and box spacing from the available height - availHeight -= iconChildren.length * (natHeight - this.iconSize) + - (iconChildren.length - 1) * spacing; - - let availSize = availHeight / iconChildren.length; + // Compute the amount of extra space (or missing space) we have + // per icon with the current icon size + let [minHeight, natHeight] = this.actor.get_preferred_height(-1); + let diff = (this._maxHeight - natHeight) / iconChildren.length; let iconSizes = [ 16, 22, 24, 32, 48, 64 ]; let newIconSize = 16; for (let i = 0; i < iconSizes.length; i++) { - if (iconSizes[i] < availSize) + if (iconSizes[i] < this.iconSize + diff) newIconSize = iconSizes[i]; } @@ -585,18 +566,20 @@ Dash.prototype = { this._box.insert_actor(addedItems[i].item.actor, addedItems[i].pos); - for (let i = 0; i < removedActors.length; i++) { - let item = removedActors[i]._delegate; + // Hide removed actors to not take them into account + // when adjusting the icon size ... + for (let i = 0; i < removedActors.length; i++) + removedActors[i].hide(); - // Don't animate item removal when the overview is hidden - if (Main.overview.visible) - item.animateOutAndDestroy(); - else - item.actor.destroy(); - } + // ... and do the same for the remove target if necessary + if (this._favRemoveTarget && this._favRemoveTarget.hiding) + this._favRemoveTarget.actor.hide(); this._adjustIconSize(); + if (this._favRemoveTarget && this._favRemoveTarget.hiding) + this._favRemoveTarget.actor.show(); + // Skip animations on first run when adding the initial set // of items, to avoid all items zooming in at once if (!this._shownInitially) { @@ -604,6 +587,17 @@ Dash.prototype = { return; } + for (let i = 0; i < removedActors.length; i++) { + removedActors[i].show(); + let item = removedActors[i]._delegate; + + // Don't animate item removal when the overview is hidden + if (Main.overview.visible) + item.animateOutAndDestroy(); + else + item.actor.destroy(); + } + // Don't animate item addition when the overview is hidden if (!Main.overview.visible) return;